import { createSlice } from "@reduxjs/toolkit";
import { kUserSlice, kSetUser } from "./userDispatch";
import type { User } from "./User";
import type { PayloadAction } from "@reduxjs/toolkit";
const userSlice = createSlice({
    name: kUserSlice,
    initialState: {
        user: null as User | null,
    },
    reducers: {
        // 设置用户信息
        [kSetUser.action]: (state, action: PayloadAction<User | null>) => {
            state.user = action.payload;
        },
    },
});

export const { setUser } = userSlice.actions;
export default userSlice.reducer;
